#ifndef EYERWANDARTIST_TIMELINE_TEST_HPP
#define EYERWANDARTIST_TIMELINE_TEST_HPP

#include <gtest/gtest.h>
#include "EWAPrj/EWAPrjHeader.hpp"

TEST(EWAPrj, Timeline_track_TEST)
{
    Eyer::EWAPrjTrackType trackType = Eyer::EWAPrjTrackType::VIDEO;

    Eyer::EWAPrjTimeline timeline;
    ASSERT_EQ(timeline.GetTrackCount(trackType), 0);

    {
        Eyer::EyerSmartPtr<Eyer::EWAPrjTrack> track(new Eyer::EWAPrjTrack());
        timeline.AddTrack(track, 0, trackType);
        ASSERT_EQ(timeline.GetTrackCount(trackType), 1);
    }
    {
        Eyer::EyerSmartPtr<Eyer::EWAPrjTrack> track(new Eyer::EWAPrjTrack());
        timeline.AddTrack(track, 0, trackType);
        ASSERT_EQ(timeline.GetTrackCount(trackType), 2);
    }
    {
        Eyer::EyerSmartPtr<Eyer::EWAPrjTrack> track(new Eyer::EWAPrjTrack());
        timeline.AddTrack(track, 0, trackType);
        ASSERT_EQ(timeline.GetTrackCount(trackType), 3);
    }

    for(int i=0;i<timeline.GetTrackCount(trackType);i++){
        Eyer::EyerSmartPtr<Eyer::EWAPrjTrack> track = timeline.GetTrack(i, trackType);
        ASSERT_NE(track, nullptr);
    }
}

TEST(EWAPrj, Timeline_serializable_TEST)
{
    Eyer::EWAPrjTrackType trackType = Eyer::EWAPrjTrackType::VIDEO;

    Eyer::EWAPrjTimeline timeline;
    {
        Eyer::EyerSmartPtr<Eyer::EWAPrjTrack> track(new Eyer::EWAPrjTrack());
        timeline.AddTrack(track, 0, trackType);
        ASSERT_EQ(timeline.GetTrackCount(trackType), 1);
    }
    {
        Eyer::EyerSmartPtr<Eyer::EWAPrjTrack> track(new Eyer::EWAPrjTrack());
        timeline.AddTrack(track, 0, trackType);
        ASSERT_EQ(timeline.GetTrackCount(trackType), 2);
    }
    {
        Eyer::EyerSmartPtr<Eyer::EWAPrjTrack> track(new Eyer::EWAPrjTrack());
        timeline.AddTrack(track, 0, trackType);
        ASSERT_EQ(timeline.GetTrackCount(trackType), 3);
        {
            Eyer::EyerSmartPtr<Eyer::EWAPrjFragment> fragment(new Eyer::EWAPrjFragmentResourse());
            track->PushFragmentBack(fragment);
        }
        {
            Eyer::EyerSmartPtr<Eyer::EWAPrjFragment> fragment(new Eyer::EWAPrjFragmentResourse());
            track->PushFragmentBack(fragment);
        }
        {
            Eyer::EyerSmartPtr<Eyer::EWAPrjFragment> fragment(new Eyer::EWAPrjFragmentResourse());
            track->PushFragmentBack(fragment);
        }
        {
            Eyer::EyerSmartPtr<Eyer::EWAPrjFragment> fragment(new Eyer::EWAPrjFragmentResourse());
            track->PushFragmentBack(fragment);
        }
    }

    Eyer::EyerString json = timeline.Serializable();

    EyerLog("\n%s\n", json.c_str());
}

TEST(EWAPrj, Timeline_parse_TEST)
{
    Eyer::EyerString json = "{}";
    Eyer::EWAPrjTimeline timeline;
    timeline.Parse(json);
}

#endif //EYERWANDARTIST_TIMELINE_TEST_HPP
